using QFramework;
using UnityEngine;

namespace QGameFramework.Models
{
    public interface IGameConfig : IModel
    {
        /// <summary>
        /// 资源最大数量
        /// </summary>
        int MaxResourcesCount { get; set; }

        /// <summary>
        /// 音效音量大小
        /// </summary>
        float SoundValue { get; set; }

        /// <summary>
        /// 是否打开音效
        /// </summary>
        bool OpenSound { get; set; }

        /// <summary>
        /// 声音大小
        /// </summary>
        float VoiceValue { get; set; }

        /// <summary>
        /// 是否打开声音
        /// </summary>
        bool OpenVoice { get; set; }

        /// <summary>
        /// 音乐大小
        /// </summary>
        float MusicValue { get; set; }

        /// <summary>
        /// 是否打开音乐
        /// </summary>
        bool OpenMusic { get; set; }

        /// <summary>
        /// 资源清理时间
        /// </summary>
        int CleanTime { get; set; }

        /// <summary>
        /// IP地址
        /// </summary>
        string IpAdr { get; set; }

        /// <summary>
        /// IP端口
        /// </summary>
        int Port { get; set; }

        /// <summary>
        /// UI分辨率
        /// </summary>
        Vector2Int UIResolution { get; set; }
    }

    public class GameConfig : AbstractModel, IGameConfig
    {
        /// <summary>
        /// 资源最大数量
        /// </summary>
        public int MaxResourcesCount { get; set; }

        /// <summary>
        /// 音乐大小
        /// </summary>
        public float MusicValue { get; set; }

        /// <summary>
        /// 音效大小
        /// </summary>
        public float SoundValue { get; set; }

        /// <summary>
        /// 人声大小
        /// </summary>
        public float VoiceValue { get; set; }


        /// <summary>
        /// 是否开启音乐
        /// </summary>
        public bool OpenMusic { get; set; }

        /// <summary>
        /// 是否打开音效
        /// </summary>
        public bool OpenSound { get; set; }

        /// <summary>
        /// 是否开启音效
        /// </summary>
        public bool OpenVoice { get; set; }

        /// <summary>
        /// 资源清理时间
        /// </summary>
        public int CleanTime { get; set; }

        public string IpAdr { get; set; }
        public int Port { get; set; }
        public Vector2Int UIResolution { get; set; }

        protected override void OnInit()
        {
            MaxResourcesCount = 0;
            SoundValue = 0.5f;
            VoiceValue = 0.5f;
            MusicValue = 0.5f;
            CleanTime = 0;
            OpenSound = true;
            OpenVoice = true;
            OpenMusic = true;
            IpAdr = string.Empty;
            Port = 0;
            UIResolution = Vector2Int.zero;
        }
    }
}